Namespace CNG
    Public Class MaestroZonaRuta

        Private _CodigoCD As String
        Private _Zona As String
        Private _Ruta As String
        Private _Supervisor As CNG.Supervisor
        Private _Distribuidor As CNG.Distribuidor
        Private _Preventista As CNG.Preventista
        Private _CodigoTipoArea As Integer

        Public Property CodigoCD() As String
            Get
                Return _CodigoCD
            End Get
            Set(ByVal value As String)
                If _CodigoCD = Value Then
                    Return
                End If
                _CodigoCD = Value
            End Set
        End Property

        Public Property Zona() As String
            Get
                Return _Zona
            End Get
            Set(ByVal value As String)
                If _Zona = Value Then
                    Return
                End If
                _Zona = Value
            End Set
        End Property

        Public Property Ruta() As String
            Get
                Return _Ruta
            End Get
            Set(ByVal value As String)
                If _Ruta = Value Then
                    Return
                End If
                _Ruta = Value
            End Set
        End Property
        Public Property Supervisor() As CNG.Supervisor
            Get
                Return _Supervisor
            End Get
            Set(ByVal value As CNG.Supervisor)
                _Supervisor = value
            End Set
        End Property
        Public Property Distribuidor() As CNG.Distribuidor
            Get
                Return _Distribuidor
            End Get
            Set(ByVal value As CNG.Distribuidor)
                _Distribuidor = value
            End Set
        End Property
        Public Property Preventista() As CNG.Preventista
            Get
                Return _Preventista
            End Get
            Set(ByVal value As CNG.Preventista)
                _Preventista = value
            End Set
        End Property
        Public Property CodigoTipoArea() As Integer
            Get
                Return _CodigoTipoArea
            End Get
            Set(ByVal value As Integer)
                If _CodigoTipoArea = Value Then
                    Return
                End If
                _CodigoTipoArea = Value
            End Set
        End Property


        Public Shared Function ListadoMaestroZonaRuta(ByVal CodigoCD As String) As DataTable

            Dim Comando As New CAD.MaestroZonaRuta.vMaestroZonaRuta_SELECT(CAD.BaseDatos.Conexion)
            Dim Tabla As New DataTable

            Comando.LoadTable(Tabla, CodigoCD)

            Return Tabla

        End Function
        Public Sub Agregar()

            Dim comando As New CAD.MaestroZonaRuta.MaestroZonaRuta_INSERT(CAD.BaseDatos.Conexion)

            comando.ExecuteNonQuery(Me.CodigoCD, _
                                    Me.Zona, _
                                    Me.Ruta, _
                                    Me.Supervisor.Codigo, _
                                    Me.Distribuidor.Codigo, _
                                    Me.Preventista.Codigo, _
                                    Me.CodigoTipoArea)

        End Sub
        Public Sub Modificar(ByVal ZonaAntigua As String, ByVal RutaAntigua As String)

            Dim comando As New CAD.MaestroZonaRuta.MaestroZonaRuta_UPDATE(CAD.BaseDatos.Conexion)

            comando.ExecuteNonQuery(Me.CodigoCD, _
                                    Me.Zona, _
                                    Me.Ruta, _
                                    Me.Supervisor.Codigo, _
                                    Me.Distribuidor.Codigo, _
                                    Me.Preventista.Codigo, _
                                    Me.CodigoTipoArea, _
                                    ZonaAntigua, _
                                    RutaAntigua)

        End Sub
        Public Sub Eliminar()

            Dim comando As New CAD.MaestroZonaRuta.MaestroZonaRuta_DELETE(CAD.BaseDatos.Conexion)

            comando.ExecuteNonQuery(Me.CodigoCD, _
                                    Me.Zona, _
                                    Me.Ruta)

        End Sub

        Public Shared Function ListadoZona(ByVal CodigoCD As String, ByVal CodigoUsuario As System.Nullable(Of Integer), ByVal CodigoTipoUsuario As String) As DataTable

            Dim Comando As New CAD.MaestroZonaRuta.MaestroZonaRuta_Zona_SELECT(CAD.BaseDatos.Conexion)
            Dim Tabla As New DataTable

            Comando.LoadTable(Tabla, CodigoCD, CodigoUsuario, CodigoTipoUsuario)

            Return Tabla

        End Function

        Public Shared Function ListadoZonaRuta(ByVal CodigoCD As String, ByVal CodigoUsuario As System.Nullable(Of Integer), ByVal CodigoTipoUsuario As String) As DataTable

            Dim Comando As New CAD.MaestroZonaRuta.MaestroZonaRuta_ZonaRuta_SELECT(CAD.BaseDatos.Conexion)
            Dim Tabla As New DataTable

            Comando.LoadTable(Tabla, CodigoCD, CodigoUsuario, CodigoTipoUsuario)

            Return Tabla

        End Function
    End Class

End Namespace
